package io.dcloud.test4050

import android.app.ActivityOptions
import android.content.Intent
import android.os.Bundle
import android.view.Gravity
import android.widget.Button
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.ScrollView
import androidx.appcompat.app.AppCompatActivity
import com.example.nativedom2test.Engine


class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {

        super.onCreate(savedInstanceState)

        Engine.context = this
        val rootView = FrameLayout(this)
        val scrollView = ScrollView(this)
        val scrollC = LinearLayout(this)
        scrollC.orientation = LinearLayout.VERTICAL
        scrollC.gravity = Gravity.CENTER

        val button1 = Button(this)
        button1.text = "view嵌套text 4050"
        button1.isAllCaps = false
        button1.setOnClickListener {
            val intent = Intent(this, ViewText4050Activity::class.java)
            val optionsCompat = ActivityOptions.makeCustomAnimation(
                this,
                R.anim.uni_app_x_pop_in_enter,
                R.anim.uni_app_x_pop_in_exit
            )
            startActivity(intent, optionsCompat.toBundle())
        }
        scrollC.addView(button1)

        val button1_1 = Button(this)
        button1_1.text = "composeUI view嵌套text 4050"
        button1_1.isAllCaps = false
        button1_1.setOnClickListener {
            val intent = Intent(this, ComposeTextToView4050Activity::class.java)
            val optionsCompat = ActivityOptions.makeCustomAnimation(
                this,
                R.anim.uni_app_x_pop_in_enter,
                R.anim.uni_app_x_pop_in_exit
            )
            startActivity(intent, optionsCompat.toBundle())
        }
        scrollC.addView(button1_1)
        scrollView.addView(scrollC)
        rootView.addView(scrollView)
        setContentView(rootView)
    }

    override fun onDestroy() {
        super.onDestroy()
        Engine.context = null
    }

}